package com.briup.controller;

import com.briup.bean.PageBean;
import com.briup.pojo.Book;
import com.briup.pojo.Student;
import com.briup.pojo.extend.BookExtend;
import com.briup.result.Result;
import com.briup.service.BookService;
import com.briup.service.StudentService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/students")
public class  StudentController {

    @Autowired
    private StudentService studentService;

//    添加学生
    @PostMapping
    public Result addStudent(@RequestBody Student student) {
        studentService.addStudent(student);
        return Result.success("添加学生成功");
    }

    //搜索学生 根据id
    //    @GetMapping("/{id}")
//    private Result getBookById(@PathVariable Integer id) {
//
//        Book book = bookService.getBookById(id);
//        return Result.success(book);
//    }











    //条件查询所有书籍-- 不分页
//    @GetMapping
//    private Result getByCondition(String keyword, Integer categoryId) {
//        System.out.println("in bookController, getByCondition() ...");
//
//        List<BookExtend> list = bookService.getBooksByCondition(keyword, categoryId);
//        return Result.success(list);
//    }
//    //条件查询所有书籍-- 分页 自己手动分页
//    @GetMapping("/page")
//    private Result getByPageCondition(String keyword, Integer categoryId,Integer pageNum,Integer pageSize) {
//        System.out.println("in bookController, getByPageCondition() ...");
//        PageBean pageBean = bookService.getBooksByConditionAndPage(keyword, categoryId, pageNum, pageSize);
//        return Result.success(pageBean);
//    }
//
//    //条件查询所有书籍-- 分页 插件分页 PageHelper
//    @ApiOperation(value = "条件查询图书信息带分页", notes = "分页插件PageHelper完成")
//    @GetMapping("/pageNew")
//    private Result getByPageConditionNew(String keyword, Integer categoryId,Integer pageNum,Integer pageSize) {
//        System.out.println("in bookController, getByPageCondition() ...");
//        PageInfo pageInfo = bookService.getBooksByConditionAndPageNew(keyword, categoryId, pageNum, pageSize);
//        return Result.success(pageInfo);
//    }
//    //添加书籍 新增图书
//    @PostMapping
//    private Result addBook(@RequestBody Book book) {
//
//        bookService.addBook(book);
//        return Result.success("添加图书成功");
//    }
//    //删除书籍
//    @DeleteMapping("/{id}")
//    private Result removeBookById(@PathVariable Integer id) {
//
//        bookService.removeBookById(id);
//        return Result.success("删除图书成功");
//    }
//    //批量删除
//    @DeleteMapping
//    private Result removeBatchByIds(@RequestBody List<Integer> ids) {
//
//        bookService.removeBatchByIds(ids);
//        return Result.success("批量删除图书成功");
//    }
//    //修改书籍信息
//    @PutMapping()
//    private Result modifyBook(@RequestBody Book book) {
//
//        bookService.modifyBook(book);
//        return Result.success("修改图书信息成功");
//    }
//    //修改书籍状态
//    @PutMapping("/{id}/{status}")
//    private Result modifyBookStatus(@PathVariable Integer id, @PathVariable Integer status) {
//
//        bookService.modifyBookStatus(id, status);
//        return Result.success("修改图书状态成功");
//    }
//    //根据id查询书籍
//    @GetMapping("/{id}")
//    private Result getBookById(@PathVariable Integer id) {
//
//        Book book = bookService.getBookById(id);
//        return Result.success(book);
//    }







}
